* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #776e65;
    font-size: 18px;
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 48px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
}

.score-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.score-box {
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 10px;
    text-align: center;
    backdrop-filter: blur(5px);
}

.score-label {
    font-size: 14px;
    color: #ffffff;
    margin-bottom: 5px;
}

.score {
    font-size: 24px;
    font-weight: bold;
    color: #ffffff;
}

.game-info {
    text-align: center;
    margin-bottom: 20px;
}

.game-info p {
    color: #ffffff;
    margin-bottom: 15px;
    font-size: 16px;
}

.restart-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.restart-btn:hover {
    background: #ff5252;
    transform: translateY(-2px);
}

.game-container {
    position: relative;
    width: 350px;
    height: 350px;
    margin: 0 auto;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    padding: 10px;
}

.grid-container {
    position: absolute;
    top: 10px;
    left: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    z-index: 1;
}

.grid-row {
    display: flex;
    margin-bottom: 10px;
}

.grid-row:last-child {
    margin-bottom: 0;
}

.grid-cell {
    width: 75px;
    height: 75px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    margin-right: 10px;
}

.grid-cell:last-child {
    margin-right: 0;
}

.tile-container {
    position: absolute;
    top: 10px;
    left: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    z-index: 2;
}

.tile {
    position: absolute;
    width: 75px;
    height: 75px;
    background: #eee4da;
    border-radius: 6px;
    font-size: 32px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.15s ease-in-out;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tile-2 { background: #eee4da; color: #776e65; }
.tile-4 { background: #ede0c8; color: #776e65; }
.tile-8 { background: #f2b179; color: #f9f6f2; }
.tile-16 { background: #f59563; color: #f9f6f2; }
.tile-32 { background: #f67c5f; color: #f9f6f2; }
.tile-64 { background: #f65e3b; color: #f9f6f2; }
.tile-128 { background: #edcf72; color: #f9f6f2; font-size: 28px; }
.tile-256 { background: #edcc61; color: #f9f6f2; font-size: 28px; }
.tile-512 { background: #edc850; color: #f9f6f2; font-size: 28px; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 24px; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 24px; }

.tile-merged {
    z-index: 3;
    animation: merge 0.15s ease-in-out;
}

@keyframes merge {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.tile-new {
    animation: appear 0.2s ease-in-out;
}

@keyframes appear {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

.game-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    z-index: 100;
    display: none;
    backdrop-filter: blur(10px);
}

.game-message.game-won {
    display: block;
    background: rgba(76, 175, 80, 0.9);
    color: white;
}

.game-message.game-over {
    display: block;
    background: rgba(244, 67, 54, 0.9);
    color: white;
}

.game-message p {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
}

@media (max-width: 520px) {
    .container {
        max-width: 280px;
        padding: 10px;
    }
    
    .header h1 {
        font-size: 36px;
    }
    
    .game-container {
        width: 260px;
        height: 260px;
        padding: 8px;
    }
    
    .grid-container {
        top: 8px;
        left: 8px;
        width: calc(100% - 16px);
        height: calc(100% - 16px);
    }
    
    .tile-container {
        top: 8px;
        left: 8px;
        width: calc(100% - 16px);
        height: calc(100% - 16px);
    }
    
    .grid-cell, .tile {
        width: 55px;
        height: 55px;
    }
    
    .tile {
        font-size: 24px;
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 20px;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 18px;
    }
}